package com.alex.seo.domain.site;

import java.util.Collection;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.alex.seo.dao.Identifieble;
import com.alex.seo.domain.page.Page;

@Entity
@Table(name = "site")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class Site implements Identifieble<Integer> {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;

	private String name;

	private String url;

	public Site() {
	}

	public Site(Integer id) {
		this.id = id;
	}

	public Site(String name, String url) {
		this.name = name;
		this.url = url;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "site")
	private Collection<Page> pages;

	@Override
	public Integer getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Collection<Page> getPages() {
		return pages;
	}

	public void setPages(Collection<Page> pages) {
		this.pages = pages;
	}

	@Override
	public String toString() {
		return getClass().getSimpleName() + " {id='" + id + "', name='" + name + "', url='" + url + "'}";
	}
}
